package com.eedi.framework.tenant.dal.mapper;

import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBasicReq;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBasicResp;
import com.eedi.framework.tenant.convert.SysSetupBasicConvert;
import com.eedi.framework.tenant.dal.dataobject.SysSetupBasicDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 系统设置
 * 基本设置
 *
 * @author zybourn
 */
@Mapper
public interface SysSetupBasicMapper extends BaseMapperX<SysSetupBasicDO> {

    default SysSetupBasicResp getSetupBasicResp() {
        return SysSetupBasicConvert.INSTANCE.convert(selectOne(new LambdaQueryWrapperX<>()));
    }

    default void setup(String sysSetupBasicId, SysSetupBasicReq req){
        SysSetupBasicDO sysSetupBasicDO = SysSetupBasicConvert.INSTANCE.convert(req);
        sysSetupBasicDO.setSysSetupBasicId(sysSetupBasicId);
        updateById(sysSetupBasicDO);
    }

    default void insert(SysSetupBasicReq req){
        SysSetupBasicDO sysSetupBasicDO = SysSetupBasicConvert.INSTANCE.convert(req);
        insert(sysSetupBasicDO);
    }
}
